package com.neuedu.web.controller.yunong;

import java.util.List;

import com.neuedu.yunong.domain.YunongExpertInformation;
import com.neuedu.yunong.service.IYunongExpertInformationService;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neuedu.common.annotation.Log;
import com.neuedu.common.core.controller.BaseController;
import com.neuedu.common.core.domain.AjaxResult;
import com.neuedu.common.enums.BusinessType;
import com.neuedu.common.utils.poi.ExcelUtil;
import com.neuedu.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 专家信息Controller
 *
 * @author mxwj
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/experts/information")
@Tag(name = "【专家信息】管理")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class YunongExpertInformationController extends BaseController
{
    private final IYunongExpertInformationService yunongExpertInformationService;

    /**
     * 查询专家信息列表
     */
    @Operation(summary = "查询专家信息列表")
    @PreAuthorize("@ss.hasPermi('experts:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(YunongExpertInformation yunongExpertInformation)
    {
        startPage();
        List<YunongExpertInformation> list = yunongExpertInformationService.selectYunongExpertInformationList(yunongExpertInformation);
        return getDataTable(list);
    }

    /**
     * 导出专家信息列表
     */
    @Operation(summary = "导出专家信息列表")
    @PreAuthorize("@ss.hasPermi('experts:information:export')")
    @Log(title = "专家信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YunongExpertInformation yunongExpertInformation)
    {
        List<YunongExpertInformation> list = yunongExpertInformationService.selectYunongExpertInformationList(yunongExpertInformation);
        ExcelUtil<YunongExpertInformation> util = new ExcelUtil<YunongExpertInformation>(YunongExpertInformation.class);
        util.exportExcel(response, list, "专家信息数据");
    }

    /**
     * 获取专家信息详细信息
     */
    @Operation(summary = "获取专家信息详细信息")
    @PreAuthorize("@ss.hasPermi('experts:information:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yunongExpertInformationService.selectYunongExpertInformationById(id));
    }

    /**
     * 新增专家信息
     */
    @Operation(summary = "新增专家信息")
    @PreAuthorize("@ss.hasPermi('experts:information:add')")
    @Log(title = "专家信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YunongExpertInformation yunongExpertInformation)
    {
        return toAjax(yunongExpertInformationService.insertYunongExpertInformation(yunongExpertInformation));
    }

    /**
     * 修改专家信息
     */
    @Operation(summary = "修改专家信息")
    @PreAuthorize("@ss.hasPermi('experts:information:edit')")
    @Log(title = "专家信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YunongExpertInformation yunongExpertInformation)
    {
        return toAjax(yunongExpertInformationService.updateYunongExpertInformation(yunongExpertInformation));
    }

    /**
     * 删除专家信息
     */
    @Operation(summary = "删除专家信息")
    @PreAuthorize("@ss.hasPermi('experts:information:remove')")
    @Log(title = "专家信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable( name = "ids" ) Long[] ids)
    {
        return toAjax(yunongExpertInformationService.deleteYunongExpertInformationByIds(ids));
    }
}
